import { createRouter, createWebHashHistory } from 'vue-router';
import { onMounted } from 'vue';
import Layout from '@/views/Layout/Layout.vue';

import AboutView from '@/views/About/AboutView.vue';
import Login from '@/views/Login/Login.vue';
import Register from '@/views/Register/Register.vue';
import StudentView from '@/views/Student/StudentHome.vue';
import Stuindex from '@/views/Student/Stuindex.vue';
import StuQA from '@/views/Student/StuQA.vue';
import Stuans from '@/views/Student/Stuans.vue'

export const router = createRouter({
  history: createWebHashHistory(), // 使用默认的历史管理器
  // 路由滚动行为定制
  scrollBehavior() {
    return {
      top: 0
    }
  },
  routes: [
    {
      path: '/',
      component: Layout,
      children: [
        {
          path: '/',
          component: Login
        },
        {
          path: '/student',
          component:StudentView
        },
        {
          path: '/studentindex',
          component:Stuindex
        },
        {
          path: '/studentqa',
          component:StuQA
        },
        {
          path: '/N14',
          component:Stuans
        },
        {
          path: '/studentrev',
          component: () => import('@/views/Student/StuReview.vue')
        },
        {
          path: '/chatlist',
          component: () => import('@/views/Student/StudentChatList.vue')
        },
        {
          path: '/mine',
          component: () => import('@/views/Student/StudentMine.vue')
        },
        {
          path: '/preview',
          component: () => import('@/views/Student/StuPreview.vue')
        },
        {
          path: '/my_class',
          component: () => import('@/views/Student/MyClass.vue')
        },
        {
          path: '/analysis',
          component: () => import('@/views/Student/analysis.vue')
        }
      ]
    },
    {
      path: '/chat/:TitleId',
      component: () => import('@/views/Student/ChatPage.vue')
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/Register',
      component: Register
    },
    {
      path: '/about',
      component: AboutView
    }
    ,
    {
      path: '/draw_graph',
      component: () => import('@/views/Student/knowledge_graph/draw_graph.vue')
    }
  ],
});

onMounted(() => {
  // 如果有需要，可以在挂载后做一些初始化操作
});

export default router

